/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ronald
 */

@Entity
@Table(name = "purchase_detail_cut_process")
public class PurchaseDetailCutProcess extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;
    private Float quantity;
    private PurchaseDetail purchaseDetail;
    private CutProcess cutProcess;
    private Material material;

    private Float quantityFail;
    private Float priceQuantityFail;

    private Float totalAmountQuantityFail;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id_purchasedetail_cutprocess")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_cut_process")
    public CutProcess getCutProcess() {
        return cutProcess;
    }

    public void setCutProcess(CutProcess cutProcess) {
        this.cutProcess = cutProcess;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_purchase_detail")
    public PurchaseDetail getPurchaseDetail() {
        return purchaseDetail;
    }

    public void setPurchaseDetail(PurchaseDetail purchaseDetail) {
        this.purchaseDetail = purchaseDetail;
    }

    @Column(name = "quantity", nullable = false)
    public Float getQuantity() {
        return quantity;
    }

    public void setQuantity(Float quantity) {
        this.quantity = quantity;
    }

    @Column(name = "price_quantity_fail")
    public Float getPriceQuantityFail() {
        return priceQuantityFail;
    }

    public void setPriceQuantityFail(Float priceQuantityFail) {
        this.priceQuantityFail = priceQuantityFail;
    }

    @Column(name = "quantity_fail")
    public Float getQuantityFail() {
        return quantityFail;
    }

    public void setQuantityFail(Float quantityFail) {
        this.quantityFail = quantityFail;
    }

    @Column(name = "total_amount_quantity_fail")
    public Float getTotalAmountQuantityFail() {
        return totalAmountQuantityFail;
    }

    public void setTotalAmountQuantityFail(Float totalAmountQuantityFail) {
        this.totalAmountQuantityFail = totalAmountQuantityFail;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                   .append(this.id).append(this.quantity)
                   .append(this.purchaseDetail.getId()).append(this.cutProcess.getId()).toString();

    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PurchaseDetailCutProcess other = (PurchaseDetailCutProcess) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.quantity != other.quantity && (this.quantity == null || !this.quantity.equals(other.quantity))) {
            return false;
        }
        if (this.purchaseDetail != other.purchaseDetail && (this.purchaseDetail == null || !this.purchaseDetail.equals(other.purchaseDetail))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 79 * hash + (this.quantity != null ? this.quantity.hashCode() : 0);
        hash = 79 * hash + (this.purchaseDetail != null ? this.purchaseDetail.hashCode() : 0);
        hash = 79 * hash + (this.cutProcess != null ? this.cutProcess.hashCode() : 0);
        return hash;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_material")
    public Material getMaterial() {
        return material;
    }

    public void setMaterial(Material material) {
        this.material = material;
    }

}
